package com.ifox.hgx.spring.hibernate.entity;

import javax.persistence.*;
import java.util.Objects;

/**
 * Copyright (C), 2017-2018, 成都艾弗克斯科技有限公司
 * Author:   hanguixian
 * Date:     2018/10/27 12:14
 * Description: ${DESCRIPTION}
 */
@Entity
public class Book {
    private int id;
    //书名
    private String bookName;
    //书号：如1001
    private String isbn;
    //价格
    private Integer price;
    //库存
    private Integer stock;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Basic
    @Column(name = "bookName")
    public String getBookName() {
        return bookName;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    @Basic
    @Column(name = "isbn")
    public String getIsbn() {
        return isbn;
    }

    public void setIsbn(String isbn) {
        this.isbn = isbn;
    }

    @Basic
    @Column(name = "price")
    public Integer getPrice() {
        return price;
    }

    public void setPrice(Integer price) {
        this.price = price;
    }

    @Basic
    @Column(name = "stock")
    public Integer getStock() {
        return stock;
    }

    public void setStock(Integer stock) {
        this.stock = stock;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Book book = (Book) o;
        return id == book.id &&
                Objects.equals(bookName, book.bookName) &&
                Objects.equals(isbn, book.isbn) &&
                Objects.equals(price, book.price) &&
                Objects.equals(stock, book.stock);
    }

    @Override
    public int hashCode() {

        return Objects.hash(id, bookName, isbn, price, stock);
    }
}
